# Maintainer: David Runge <dvzrv@archlinux.org>

_name=blop-lv2
pkgname=blop.lv2
pkgver=1.0.4
pkgrel=2
pkgdesc="A port of the BLOP LADSPA plugins by Mike Rawes to LV2."
arch=(loong64 x86_64)
url="https://gitlab.com/drobilla/blop-lv2"
license=(GPL3)
groups=(lv2-plugins pro-audio)
depends=(gcc-libs glibc lv2-host)
makedepends=(lv2 meson)
checkdepends=(lv2lint)
options=(debug)
source=(https://download.drobilla.net/$_name-$pkgver.tar.xz{,.sig})
sha512sums=('daca11d7b692f279f829e7574b1139a2e571782b10c5bd5ae43a4d6e14df0b2cfab2d21e726e321e850dc093a691a039ce33dc5fa4fa1d02b912131ef00a91cb'
            'SKIP')
b2sums=('4e69f1a3b23b9f15b40dc728b8f2598038a4724a702d333b1355ee8afb9b08271f235115b93b1d25a046dfcc044bc3c9ee522fe9cb05548008a49aad689ffb18'
        'SKIP')
validpgpkeys=(907D226E7E13FA337F014A083672782A9BF368F3)  # David Robillard <d@drobilla.net>

build() {
  arch-meson $_name-$pkgver build -D tests=disabled
  meson compile -C build
}

check() {
  local plugin_names=(
    adsr
    adsr_gt
    amp
    branch
    dahdsr
    difference
    fmod
    interpolator
    lp4pole
    product
    pulse
    quantiser_100
    quantiser_20
    quantiser_50
    random
    ratio
    sawtooth
    sequencer_16
    sequencer_32
    sequencer_64
    square
    sum
    sync_pulse
    sync_square
    tracker
    triangle
  )
  local plugin_name
  local uri

  for plugin_name in "${plugin_names[@]}"; do
    uri="http://drobilla.net/plugins/blop/$plugin_name"
    printf "Testing %s using lv2lint...\n" $uri
    # NOTE: skip broken tests: https://gitlab.com/drobilla/blop-lv2/-/issues/2
    lv2lint -Mpack -t "Port Morph Port" -I build/$pkgname/ $uri
  done
}

package() {
  meson install -C build --destdir "$pkgdir"
  install -vDm 644 $_name-$pkgver/{AUTHORS,NEWS,README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
